﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NetCoreCMS.Common;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;

namespace NetCoreCMS.Web.Areas.WebApi.Controllers
{
    public class Feedback_AddController : BaseController
    {
        public IFeedbackService _feedback { get; set; }
        [HttpGet]
        public IActionResult Get(string title,string content,string name,string tel)
        {
            Feedback model = new Feedback();            
            if (string.IsNullOrEmpty(content))
            {
                return Ok(new { status = 0, msg = "请输入留言的内容！" });
            }
            model.title = Utils.DropHTML(title);
            model.content = Utils.ToHtml(content);
            model.user_name = Utils.DropHTML(name);
            model.user_tel = Utils.DropHTML(tel);
            model.user_qq = Utils.DropHTML(tel);
            model.user_email = Utils.DropHTML(tel);
            model.add_time = DateTime.Now;
            model.is_lock = 1; //不需要审核，请改为0
            if (_feedback.Add(model) > 0)
            {
                return Ok(new { status = 1, msg = "留言提交成功！" });
            }
            return Ok(new { status=0,msg= "保存过程中发生错误！" });
        }
    }
}